package main

type RoomMgr struct {
	roomArr []Room
}

func newRoomMgr(roomCount int) *RoomMgr {
	rm := RoomMgr{}
	rm.init(roomCount)
	return &rm
}

func (rm *RoomMgr) init(roomCount int) {

	rm.roomArr = make([]Room, roomCount)
	for i := 0; i < len(rm.roomArr); i++ {
		rm.roomArr[i] = Room{}
		rm.roomArr[i].Init(i)
	}
}

func (rm *RoomMgr) GetRoom(roomId int) *Room {
	if rm.isVaildId(roomId) {
		return &rm.roomArr[roomId]
	}
	return nil
}

func (rm *RoomMgr) isVaildId(roomId int) bool {
	return roomId >= 0 && roomId < len(rm.roomArr)
}

func (rm *RoomMgr) GetRoomCount() int {
	return len(rm.roomArr)
}
